package br.com.viewcar.service;

import java.util.List;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import br.com.viewcar.entity.Ponto;
import br.com.viewcar.util.CheckrotaUtil;

@Repository
@Transactional
public class PontoService extends BaseService<Integer, Ponto> {

	@Transactional
	public Ponto save(Ponto ponto) {

		ponto.setStatus(true);
		return super.save(ponto);
	}

	@Transactional
	public Ponto delete(Integer id) {

		Ponto ponto = retrieve(id);
		ponto.setStatus(false);
		update(ponto);
		return ponto;
	}

	@Transactional(readOnly = true)
	public List<Ponto> retrieveAll() {

		if(CheckrotaUtil.isAdministradorSistema()) {
			return executeResultListQuery("findAll");
		}
		return null;
	}

}